home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / swazblanker26 / docs / dev / exampleblanker.c < prev    next >
C/C++ Source or Header  |  1995-01-25  |  4KB  |  145 lines

  1. /*
  2. **  $VER: Example 2.6 (25.01.95)
  3. **  SwazBlanker Release 2.6
  4. **
  5. **  Example SwazBlanker Module Source
  6. **
  7. **  (C) Copyright 1992-95 David Swasbrook,
  8. **         All Rights Reserved
  9. */
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/dos.h>
  13. #include <proto/intuition.h>
  14. #include <proto/swazblanker.h>
  15. #include <libraries/swazblanker.h>
  16.  
  17. struct SwazBlankerBase *SwazBlankerBase;
  18.  
  19. /*
  20. ** Standard version string
  21. */
  22. extern UBYTE VersionStr[] = "$VER: ExampleBlanker 2.6 (25.01.95)";
  23. extern UBYTE NameStr[] = "ExampleBlanker";
  24. /*
  25. ** SwazBlanker ID string
  26. */
  27. extern UBYTE ID[] = "$BLANKER:"
  28.         " CPU=68000"
  29.         " KS=39"
  30.         " LOAD=None"
  31.         " STACK=4096"
  32.         " AUTHOR=\"David Swasbrook\""
  33.         " EMAIL=\"swaz@iconz.co.nz\""
  34.         " TITLE=\"Example Blanker\""
  35.         " CYEARS=\"1994\""
  36.         "This is an example blanker that is just a simple blank screen."
  37.         "\n";
  38.  
  39.  
  40.  
  41. /****** exampleblanker/Prefs() ***********************************
  42. *
  43. * SYNTAX
  44. *    Prefs()
  45. *
  46. * FUNCTION
  47. *    This is the preferences configuration interface for
  48. *    the blanker.
  49. *
  50. * NOTE
  51. *    Your user-interface should use the same font as set in
  52. *    the SwazBlanker preferences. This can be obtained
  53. *    from the SwazBlanker semaphore ssem->InterfaceFont.
  54. *    This is  pointer to a string, Eg "Helvetica 11".
  55. *
  56. *****************************************************************/
  57. void Prefs(void)
  58. {
  59.     struct EasyStruct es = {
  60.         sizeof(struct EasyStruct),
  61.         0,
  62.         "Example Blanker",
  63.         "No configuration required",
  64.         "Help|Exit" };
  65.     struct BlankerPrefsNode *bpn;
  66.     APTR SBHelp=NULL;
  67.  
  68.     if( bpn = SB_AddPrefsTaskTagList( &*NameStr, NULL ) )
  69.     {
  70.         while( EasyRequest(NULL,&es,NULL,NULL) )
  71.         {
  72.             SBHelp = SB_HelpTags( "Example", NULL,
  73.         SBHELP_BlankerPrefs, bpn,
  74.         SBHELP_Directory, TRUE,        
  75.         TAG_DONE);
  76.         }
  77.         SB_HelpClose( SBHelp );
  78.         SB_RemPrefsTask( bpn );
  79.     }
  80.  
  81. }
  82.  
  83. /****** exampleblanker/Blank() ***********************************
  84. *
  85. * SYNTAX
  86. *    Blank()
  87. *
  88. * FUNCTION
  89. *    This is the actual blanker routine.
  90. *
  91. *****************************************************************/
  92. void Blank(void)
  93. {
  94.     struct Screen *screen;
  95.     struct Window *window;
  96.     WORD CSpec[] = { 0,0,0,0, -1 };
  97.  
  98.     screen = SB_OpenScreenTags(
  99.             SA_DisplayID,0,
  100.             SA_Depth,1,
  101.             SA_Colors, &CSpec,
  102.             TAG_DONE);
  103.  
  104.     if(screen)
  105.     {
  106.         window = SB_OpenWindowTags(
  107.                   WA_CustomScreen,screen,
  108.                   TAG_DONE);
  109.  
  110.         if(window)
  111.         {
  112.             SB_SetBlankerScreen( screen, window );    /* Set the blankers screen and window */
  113.             SB_BlankerReady();                        /* Tell SwazBlanker we are working */
  114.             Wait(SIGBREAKF_CTRL_C);                   /* Wait for abort signal */
  115.             SB_ClrBlankerScreen( screen, window );    /* Restore old screen */
  116.             CloseWindow(window);
  117.         }
  118.         CloseScreen(screen);
  119.     }
  120. }
  121.  
  122. /****************************************************************
  123.  
  124.  ***************************************************************/
  125. void main (int argc, char **argv)
  126. {
  127.     LONG  arg[] = { 0 , 1 };
  128.     APTR  argLock, dirLock;
  129.  
  130.     if( SwazBlankerBase = (struct SwazBlankerBase *) OpenLibrary( "swazblanker.library", 41 ) )
  131.     {    
  132.         if (argLock = ReadArgs ("BLANK/S,PREFS/S",&*arg,NULL))
  133.         {
  134.             dirLock = SB_GotoBlankerHomeDir();       /* Take us to the blanker directory */
  135.  
  136.             if( arg[0] ) Blank(); else Prefs();      /* Do either the BLANK or PREFS option */
  137.  
  138.             SB_ReturnBlankerHomeDir( dirLock );      /* Restore original directory lock */
  139.  
  140.             FreeArgs(argLock);
  141.         }
  142.         CloseLibrary( (struct Library *) SwazBlankerBase );
  143.     }
  144. }
  145.